home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / misc / MakeDayDateH.lha / MakeDayDateH / makedaydateh.c < prev    next >
C/C++ Source or Header  |  1993-02-01  |  2KB  |  66 lines

  1. /*
  2.  * MakeDayDateH.c
  3.  *
  4.  * Small utility to make C header file containing current day/date
  5.  * in system boot. 
  6.  * This way you have always correct date/day in your projects.
  7.  *
  8.  * Redirect the output e.g. "MakeDayDateH >env:release_date.h"
  9.  *
  10.  * All done by MKsa  (internet: k114636@ee.tut.fi)
  11.  *
  12.  *                                   'Be Careful Out There, Fellaz'
  13.  */
  14.  
  15. #include <exec/libraries.h>
  16. #include <libraries/dos.h>
  17. #include <dos/datetime.h>
  18. #include <proto/exec.h>
  19. #include <proto/dos.h>
  20. #include <clib/alib_protos.h>
  21. #include <clib/alib_stdio_protos.h>
  22. #include <strings.h>
  23.  
  24. #include "makedaydateh.h"
  25.  
  26. #define NOTESTR "/* Current day and date */\n\n"
  27. #define DEFDAY  "#define CURRENT_DAY  \""
  28. #define DEFDATE "#define CURRENT_DATE \""
  29. #define DEFEND  "\"\n"
  30.  
  31. UBYTE *VersionString = "$VER: MakeDayDateH 1.0 by MKsa (1-Feb-93)";
  32. /* note: SPACEs are <ALT SPACE>s, because c:version screws up the date */
  33.  
  34. void main(int argc, char **argv)
  35. {
  36. struct Library *DOSLibrary;
  37. struct DateTime dt;
  38. char   date[LEN_DATSTRING], day[LEN_DATSTRING],*datept;
  39. BPTR   fh;
  40.  
  41. if (!(DOSLibrary = OpenLibrary("dos.library", 0))) return;
  42.  
  43. DateStamp(&dt.dat_Stamp);
  44. dt.dat_Format = FORMAT_DOS; /* Format:   dd-mmm-yy */
  45. dt.dat_Flags = 0;
  46. dt.dat_StrDay = day;
  47. dt.dat_StrDate = date;
  48. dt.dat_StrTime = NULL;
  49. DateToStr(&dt);
  50. datept = date;
  51. if (*datept=='0') datept++; /* e.g. make "08-Dec-92" to "8-Dec-92" */
  52.  
  53. fh = Output();
  54. Write(fh,NOTESTR,strlen(NOTESTR));
  55.  
  56. Write(fh,DEFDAY,strlen(DEFDAY));
  57. Write(fh,day,strlen(day));
  58. Write(fh,DEFEND,strlen(DEFEND));
  59.  
  60. Write(fh,DEFDATE,strlen(DEFDATE));
  61. Write(fh,datept,strlen(datept));
  62. Write(fh,DEFEND,strlen(DEFEND));
  63.  
  64. CloseLibrary(DOSLibrary);
  65. }
  66.